package com.smedi.ismedi.constructionproject.core.port.adapter.service.impl;


import com.smedi.ismedi.constructionproject.core.application.command.TaskRecordCreateCommand;
import com.smedi.ismedi.constructionproject.core.application.command.TaskRecordEditCommand;
import com.smedi.ismedi.constructionproject.core.port.adapter.restful.convert.AdapterConverter;
import com.smedi.ismedi.constructionproject.core.port.adapter.service.TaskRemoteService;
import com.smedi.ismedi.inmail.api.dto.request.TaskRecordRequest;
import com.smedi.ismedi.inmail.api.feign.RemoteTaskFeignApi;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class TaskRemoteServiceImpl implements TaskRemoteService {

    private final RemoteTaskFeignApi remoteTaskFeignApi;

    private final AdapterConverter adapterConverter;


    @Override
    public void createTask(TaskRecordCreateCommand taskRecordCreateCommand) {
        TaskRecordRequest taskRecordRequest = adapterConverter.createCommandToTaskRecord(taskRecordCreateCommand);
        remoteTaskFeignApi.postAddTask(taskRecordRequest);
    }

    @Override
    public void editTask(TaskRecordEditCommand taskRecordEditCommand) {
        TaskRecordRequest taskRecordRequest = adapterConverter.editCommandToTaskRecord(taskRecordEditCommand);
        remoteTaskFeignApi.postUpdateTask(taskRecordRequest);
    }
}
